package service;

import java.util.ArrayList;

import dao.WatchedDao;
import entity.User;
import entity.Watched;

public class WatchedFilmService {
	
	WatchedDao watchedDao = new WatchedDao();

	public void addUserToWatchedFilm(User user, int movieId) {
		watchedDao.insertWatchedFilm(user, movieId);
	}
	
	public ArrayList<Watched> getWatchedFilmsByUser(User user) {
		return watchedDao.selectWatchedFilmsByUser(user);
	}
	
	public boolean isWatchedByUser(int id,User user) {
		ArrayList<Watched> watched=getWatchedFilmsByUser(user);
		for (Watched w : watched) {
			if(w.getMovieId()==id)
				return true;
		}
		return false;
	}

}
